import request from '../utils/request'
import type { ApiResponse, PageResult } from '../types/api'

export interface Prize {
  id: number
  name: string
  value: number
  image: string
  count: number
  createTime: string
  updateTime: string
}

export interface PrizeQuery {
  current: number
  size: number
  name?: string
}

export const prizeApi = {
  // 获取奖品列表
  getList(params: PrizeQuery) {
    return request.get<ApiResponse<PageResult<Prize>>>('/api/lottery/prize/list', { params })
  },

  getById(id: number): Promise<ApiResponse<Prize>> {
    return request.get<ApiResponse<Prize>>(`/api/lottery/prize/${id}`)
  },

  // 添加奖品
  save(data: Omit<Prize, 'id' | 'createTime' | 'updateTime'>) {
    return request.post<ApiResponse<void>>('/api/lottery/prize', data)
  },

  // 更新奖品
  update(id: number, data: Omit<Prize, 'id' | 'createTime' | 'updateTime'>) {
    return request.put<ApiResponse<void>>(`/api/lottery/prize/${id}`, data)
  },

  // 删除奖品
  delete(id: number) {
    return request.delete<ApiResponse<void>>(`/api/lottery/prize/${id}`)
  }
} 